<#include "/common/head.html"/> 
<table id="dg"></table>
<div id="tb" style="padding:2px 5px;">
      <!-- <a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-plus" plain="true" onclick="add()">添加规则</a> -->
   	<!-- <a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-remove" plain="true" onclick="delete1()">删除</a> -->
	<a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-remove" plain="true" onclick="back()">返回</a>
	<div>
		<a class="easyui-linkbutton color1 l-btn l-btn-small" href="javascript:void(0)" onclick="javascript:save();" style="width: 220px;">
			 <span class="l-btn-center" style="margin-top: 0px;"><span class="l-btn-text">确定</span></span> 
			 <input type="hidden" value="${setId!''}" id="hid_setId">
		</a>
	</div>
</div>
	
<script type="text/javascript">
var setId=$("#hid_setId").val();
function save() {
	var rowsSel = datagrid.datagrid("getSelections");
	var dataarr=new Array()
	for(var i=0;i<rowsSel.length;i++){
		dataarr[i]=rowsSel[i].id;
	}
	 if(rowsSel.length <= 0) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	location.replace('datasave?dataarr='+dataarr.toString()+"&setId="+setId); 
}

var datagrid = $("#dg");

var dgOptions = {
        rownumbers:true,
    	fit:true,
    	border:false,
    	striped:true,
        rownumbers:true,
    	url:'detail2List?setId='+setId,
    	method:'post',
    	toolbar:'#tb',
    	pageSize: 20,
    	pagination:true,
    	multiSort:true,
    	singleSelect:false,
//         queryParams: getInitParam(),
        columns: [[
				
					{field:'name', title: '规则名称', width:100}
				   ,{field:'ruleCode', title: '规则编号', width:100}
		           ,{field:'type',title: '规则类型', width:80}
				   ,{field:'description',title: '规则描述', width:280}
				   ,{field:'store',title: '分值', width:80}
	           ]]
	};
$(function() {
	datagrid.datagrid(dgOptions);
});

 
		
function add() {
	location.replace('add');
}
function update() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	var id = rowsSel[0].id;
	location.replace('update?id='+id);
}

function back() {
	location.replace('list');
}

function delete1() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	var name = rowsSel[0].name;
	confirmMsg("确认删除吗？", function() {
/* 		var bb="";
		for (var i = 0; i < rowsSel.length; i++) {
			var aa = rowsSel[i].positionid;
			bb = aa + "|" +bb;
		} */
		var name = rowsSel[0].name;
		$.post("delete", {name: name}, function(data) {
			var result = data.result;
			if(result=='success'){
				showMsg("删除成功！");
				datagrid.datagrid("reload");
			}else{
				showWarnMsg(result);
        		return;
			}
		});
	});
}

function zcurdSearch() {
	location.replace('detail');
}
</script>
<#include "/common/dialogWindow.html"/>
<#include "/common/foot.html"/>